<?php 
/*****************
*页面调用价格或版本数据
*创建日期:2012-5-8
*作者：yuantuan
******************/
header("expires:mon,26 jul 1997 05:00:00 gmt");  
header("cache-control:no-cache,must-revalidate");  
header("pragma:no-cache");
define('IN_WONDERSHARE', true);

if( $_GET['code'] != md5('product') ) {
	exit('error code!');
}

require( '../../inc/config.inc.php');
require( '../../includes/cls_mysql.php');
require( '../../inc/Function.php');
if(empty($db))
{
	$db = new cls_mysql($db_host, $db_user, $db_pass, $db_name);
}

/**
* 函数名：getProductInformation($db)
* 描述：得到产品价格或版本
* @params $db 操作数据库对象
* @params $productId 产品id
* @params $info 产品获取内容信息
* @return  int
*/
function getProductInformation($db,$productId,$info)
 {
						
			$sql = "SELECT `won_product_id` FROM `won_product` 
					WHERE `won_product_delete` = 0 AND `id` = '{$productId}'";	
			$id = $db->getOne($sql);
	if ($info=='price')
	{
		//price 
			$sql = "SELECT count(*) AS total FROM `license` 
					WHERE `license_id` = 11 AND `website_display` = 1 AND `license_delete` = 0 AND `product_id` = '{$id}'";
			$total = $db->getOne($sql);

			if( $total )
			{			
				$sql = "SELECT `product_is_year_charge` FROM product WHERE `product_delete` = 0 AND `product_id` = '{$id}'";
				$product_year = $db->getOne($sql);
	
				$price_one = get_price_license( $id, 11);
				$product_price = explode(',', $price_one['curr']);
				
				$price = 'R$ '.$product_price[0].','.$product_price[1];//目前价格
				$price_old = isset($price_one['unique']) ? '<del>'.'R$ '.$price_one['old'].'</del>' : '';//促销前价格
				if($product_year) $price = $product_year ? '/Year' : '';//是否一年的费用
				$str = $price_old.' '.$price;
			}		
		
     }
	 elseif($info=='version')
	 {
			$sql = "SELECT `version_name` FROM `version` 
					WHERE `is_sale` = 1 AND `product_id` = '{$id}'";
			$version_name = $db->getOne($sql);
			if( $version_name )
			{			
				$str = $version_name;
			}	
	 }
			
	return $str; 
}
echo getProductInformation($db,$_GET['id'],$_GET['info']);

?>